﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace AwesomeGame.Screens.Controls
{
    public class Messages
    {
        private List<string> _messages;
        private Vector2 _position;
        private SpriteFont _font;
        private bool _visible;

        public Messages(Vector2 position)
        {
            _position = position;
            _messages = new List<string>();
            _font = Game1.ContentManager.Load<SpriteFont>(@"Fonts\candc16pt");
            _visible = true;
        }

        public void AddMessage(string message)
        {
            if (_messages.Count > 10)
                _messages.RemoveAt(0);
            _messages.Add(message);
        }

        public void ToggleDisplay()
        {
            _visible = !_visible;
        }

        public void Update(GameTime gameTime)
        {
        }

        public void Draw(GameTime gameTime)
        {
            int c = 0;
            if(_visible)
                for (int i = _messages.Count - 1; i >= 0; i--)
                {
                    Game1.SpriteBatch.DrawString(_font, _messages[i], new Vector2(_position.X, _position.Y + (c * 15)), Color.Green);

                    c += 1;
                }
        }
    }
}
